#ifndef _DATE_H_
#define _DATE_H_

#include "dict.h"

/* date_is_newer, tell which expire date is newer
 * new_expire: new expire date
 * old_expire: old_expire
 * return 1 if new_expire is newer than old_expire, or 0 if not
 */
int date_is_newer(struct tm* new_expire, struct tm* old_expire);

/* date_newer, get the newer expire date
 * return the newer one in expire date a and b
 */
struct tm* date_newer(struct tm* a, struct tm* b);

/*
 * date_expired, tell if expire_date has expired
 */
int date_expired(struct tm* expire_date);

/*
 * date_string_expired, tell if the date of date_str has expired
 * return 1 if expired, or 0 if not
 */
int date_string_expired(const char* date_str);

/*
 * date_encrypt_with_dict, encrypt date_str with dicts
 * date_str: string of a date
 * dicts: dictionary
 * return encrypted date string, 
 */
char* date_encrypt_with_dict(const char* date_str, struct dict_set* dicts);

/*
 * date_string_to_tm, convert date string to struct tm
 */
struct tm* date_string_to_tm(const char* date_str);

/*
 * date_decrypt_with_dict, decrypt encrypted_date string with dicts to struct tm
 */
struct tm* date_decrypt_with_dict(const char* encrypted_date, struct dict_set* dicts);

/*
 * date_diff_expiration, get number of days from now to expire date
 */
int date_diff_expiration(struct tm* expire);

/*
 * _same_expire_date, check if the expire date in vikey and in system are the same
 * return 1 if yes, or 0 if not
 */
int _same_expire_date(const char* ukey_expire, const char* expire_date);


#endif
